package com.ydgk.service;

import com.ydgk.bean.User;
import com.ydgk.dao.UserDao;

import java.util.List;

public class UserService  {
    private UserDao userDao=new UserDao();

    public int save(User user){
        return userDao.save(user);
    }

    public List<User> findAll(){
        return userDao.findAll();
    }

    public int deleteById(int uid){
        return userDao.deleteById(uid);
    }

    public User login(User user){
        return userDao.login(user);
    }

    public int updateById(User user){
        return userDao.updateById(user);
    }

    public User findById(int id){
        try {
            return userDao.findById(id);
        }catch (NullPointerException e){
            return null;
        }
    }

    public int findByName(String uname){
        UserDao userDao=new UserDao();
        return userDao.findByName(uname);
    }

    public List<User> paging (int pageNumber){
        return userDao.paging(pageNumber);
    }

    public int updatemoney(User user,int money){
        return userDao.updateMoneyById(user,money);
    }

    public int maxPage(String table){
        return userDao.maxPage(table);
    }

    public int total(){return userDao.total();}

}
